package com.example.shixi_a.myapplication.home.home;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.annotation.Nullable;

import com.example.shixi_a.myapplication.R;
import com.example.shixi_a.myapplication.home.work.workTask.tasks.TasksPresenter;
import com.example.shixi_a.myapplication.model.task.TaskRepository;

/**
 * Created by yhj on 2017/9/8.
 */

public class Fragment_home extends Fragment {

    private static final String CURRENT_FILTERING_KEY = "CURRENT_FILTERING_KEY";

    //
    private TasksPresenter mTasksPresenter;

    // 请求数据
    private TaskRepository taskRepository;


    @Override
    public void onResume() {

        super.onResume();
//        mTasksPresenter.start();

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);

        // 绑定之后数据展示
//        //view层绑定
//        TasksFragment tasksFragment = (TasksFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
//        if (tasksFragment == null) {
//            //create the fragment
//            tasksFragment = TasksFragment.newInstance();
//
//            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), tasksFragment, R.id.contentFrame);
//        }
//
//        //create presenter P层构造 数据注入
//
//        taskRepository = new TaskRepository();
//
//        mTasksPresenter = new TasksPresenter(taskRepository, tasksFragment, getApplicationContext());//Injection.provideTasksRepository(getApplicationContext())
//
//        // Load previously saved state, if available.
//        if (savedInstanceState != null) {
//            TasksFilterType currentFiltering = (TasksFilterType) savedInstanceState.getSerializable(CURRENT_FILTERING_KEY);
//            mTasksPresenter.setFiltering(currentFiltering);
//        }

        return view;
    }

//    @Override
//    public void onSaveInstanceState(Bundle outState) {
//        outState.putSerializable(CURRENT_FILTERING_KEY, mTasksPresenter.getFiltering());
//        super.onSaveInstanceState(outState);
//    }

}
